<?php
declare (strict_types = 1);

namespace app\api\model\v1;

use think\Model;

/**
 * @mixin \think\Model
 */
class MonthlyTest extends AppModel
{
    //

    const JANUARY = 1;
    const FEBRUARY  = 2;
    const MARCH = 3;
    const APRIL = 4;
    const MAY = 5;
    const JUNE = 6;
    const JULY = 7;
    const AUGUST = 8;
    const SEPTEMBER = 9;
    const OCTOBER = 10;
    const NOVEMBER = 11;
    const DECEMBER = 12;

    /**
     * Notes:
     * User: liuhailong
     * DateTime: 2022/7/1 16:25
     * @var string[] 月份
     */
    public static $month  = array(
        self::JANUARY => '一月',
        self::FEBRUARY => '二月',
        self::MARCH => '三月',
        self::APRIL => '四月',
        self::MAY => '五月',
        self::JUNE => '六月',
        self::JULY => '七月',
        self::AUGUST => '八月',
        self::SEPTEMBER => '九月',
        self::OCTOBER => '十月',
        self::NOVEMBER => '十一月',
        self::DECEMBER => '十二月'
    );


    public function user(){
        return $this->belongsTo(Users::class,'user_id')->field('id,username');
    }
    //查询已经删除的用户
    public function removeUser(){
        return $this->belongsTo(Users::class,'user_id')->field('id,username')->removeOption('soft_delete');

    }

    public function unit(){
        return $this->belongsTo(Unit::class,'unit_id')->field('id,unit_title');
    }


    public function learn(){
        return $this->belongsTo(Learn::class,'learn_id')->field('id,title');
    }

    public function topic(){
        return $this->hasMany(LearnTopic::class,'learn_id','learn_id');
    }
}
